package com.fanjia.demo_qr.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

/**
 * @author fanjia
 * @description TODO
 * @date 2021/7/16 13:22
 */
@RestController
public class UserController {


    @RequestMapping("/user")
    public String showName(String data, HttpServletRequest request) throws IOException {

        ByteArrayOutputStream outSteam = null;

            InputStream inStream = request.getInputStream();
            outSteam = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            int len;
            while ((len = inStream.read(buffer)) != -1) {
                outSteam.write(buffer, 0, len);
            }

        String result = new String(outSteam.toByteArray(), StandardCharsets.UTF_8);
        System.out.println(result);


        return result;
    }












}
